package com.xzl.configclient;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
@EnableDiscoveryClient
public class ConfigClientApplication {

	public static void main(String[] args) {
		SpringApplication.run(ConfigClientApplication.class, args);
	}

	@Value("${age}")
	String age;

	@Value("${name}")
	String name;

	@Autowired
	private Environment environment ;

	@RequestMapping(value = "/hi")
	public String hi() {
		return name + " " + age;
	}

	@RequestMapping("/hi2")
	public  String   getHello2() {
		return environment.getProperty("name", "未定义")+environment.getProperty("age", "未定义");
	}
}
